import java.util.ArrayDeque;

/**
 * @Author: Lenovo
 * @Date: 2024/7/18 22:09
 * @description:
 */
public class MyQueueUseStack {
    public ArrayDeque<Integer> stack1;
    public ArrayDeque<Integer> stack2;
    public MyQueueUseStack() {
        stack1 = new ArrayDeque();
        stack2 = new ArrayDeque();
    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        if (empty()){
            return -1;
        }
        if (stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();

    }

    public int peek() {
        if (empty()){
            return -1;
        }
        if (stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();


    }

    public boolean empty() {
        return stack1.isEmpty()&&stack2.isEmpty();
    }
}
